<script src="ajax/kabupaten.js" type="text/javascript"></script>
<div class="col-md-9">
  <!-- random product -->
  <div class="span12">
	<div class="outer-border nav-page-sidebar-p10">
	  <div class="nav-judul bg-texture">
		<span class="judul-sidebar">
		  Keranjang Belanja
		</span>
	  <div class="clearfix"></div>
	  </div>
	  <div class="nav-page-sidebar-p10">
		<div class="table-responsive" id="checkout">
		  <table class="table table-hover small">
			<!-- baris judul -->
			<thead>
			  <tr>
				<th>Gambar</th>
				<th>Nama Barang</th>
				<th>Ukuran</th>
				<th>Harga</th>
				<th width="12%">Diskon (%)</th>
				<th width="10%">Kuantitas</th>
				<th width="15%">Subtotal</th>
				<th>Aksi</th>
			  </tr>
			</thead>
			<!-- end baris judul -->
			<!-- baris isi produk dibeli -->
			<?php
				$sttmt = $koneksi->query("select o.id_temp,p.id_produk,p.nama_produk,p.gambar,p.harga,o.jumlah,u.id_ukuran,u.ukuran,o.diskon,p.slug from order_temp o inner join produk p on p.id_produk = o.id_produk left join ukuran u on u.id_ukuran = o.id_ukuran where o.id_session = '$id_session'");
				while($hasil = $sttmt->fetch(PDO::FETCH_ASSOC)){
			?>
				<tbody>
				  <tr>
					<td><img src="produk/<?php echo $hasil['gambar']?>" height="50"></td>
					<td><?php echo "<a href='produk-$hasil[slug]'><b>$hasil[nama_produk]</b></a>"; ?></td>
					<td>
						<?php
							if($hasil['id_ukuran'] == '1'){
								echo "-";
							}else{
								echo $hasil['ukuran'];
							}
						?>
					</td>
					<td><?php echo "Rp. ".harga($hasil['harga'])?></td>
					<td><?php echo $hasil['diskon']; ?></td>
					<td><?php echo $hasil['jumlah']; ?></td>
					<td>
						<?php 
							$sub_total = $hasil['jumlah'] * $hasil['harga'] - ($hasil['jumlah'] * $hasil['harga'] * $hasil['diskon']/100);
							echo "Rp. ".harga($sub_total);
						?>
					</td>
					<td>
					<?php echo "<a href='#' class='btn btn-danger btn-sm' onClick='delete_cart(".$hasil["id_temp"].")'><span class='glyphicon glyphicon-trash'></span></a>"; ?>
					</td>
				  </tr>
				</tbody>
			<?php
				$total = $total + $sub_total;
				}
			?>
			<!-- baris isi produk dibeli -->
			<!-- baris jumlah -->
			<thead>
			  <tr>
				<th colspan="5"></th>
				<th>Jumlah</th>
				<th><?php echo "Rp. ".harga($total); ?></th>
				<th></th>
			  </tr>
			</thead>
			<!-- end baris jumlah -->
		  </table>
		  <i>Harga belum ternasuk ongkos kirim.</i>
		</div>
	  <div class="clearfix"></div>
	  </div>

<?php
	if($_SESSION['id_member'] != ''){
		$member = $koneksi->query("SELECT * from member m inner join kabupaten k on m.id_kabupaten = k.id_kabupaten inner join provinsi p on p.id_provinsi = k.id_provinsi where id_member = '$_SESSION[id_member]' and id_member <> 'BOS000'");
		$data = $member->fetch(PDO::FETCH_ASSOC);
	}
?>
  <!-- random product -->
	  <div class="nav-judul bg-texture">
		<span class="judul-sidebar">
		  Data Diri
		</span>
	  <div class="clearfix"></div>
	  </div>

	  <div class="nav-page-kanan">
		  <form class="form-horizontal" role="form" method="post" action="simpan.aspx" onsubmit="return gsValidate('nama|telp|email|email|alamat|provinsi|kabupaten|kd_pos','Nama Harus Diisi|Telp Harus Diisi|Email Harus Diisi||Alamat Harus Diisi|Provinsi Harus Dipilih|Kabupaten/Kota Harus Dipilih|Kode Pos Harus Diisi','required|required_numeric|required|email|required|required|required|required_numeric');">
			  <div class="form-group">
				<label class="col-lg-3 control-label small">Nama</label>
				<div class="col-lg-7">
				  <input type="text" class="form-control input-sm" name="nama" value="<?php echo $data['nama_lengkap']; ?>" placeholder="Nama..." id="nama" maxlength="50">
				</div>
			  </div>
			  <div class="form-group">
				<label class="col-lg-3 control-label small">No. Telp</label>
				<div class="col-lg-7">
				  <input type="text" class="form-control input-sm" name="telp" value="<?php echo $data['no_telp']; ?>" placeholder="No. Telp..." id="telp" maxlength="20">
				</div>
			  </div>
			  <div class="form-group">
				<label class="col-lg-3 control-label small">Email</label>
				<div class="col-lg-7">
				  <input type="text" class="form-control input-sm" name="email" value="<?php echo $data['email']; ?>" placeholder="Email..." id="email" maxlength="30">
				</div>
			  </div>
			  <div class="form-group">
				<label class="col-lg-3 control-label small">Alamat Lengkap</label>
				<div class="col-lg-7">
				  <textarea name="alamat" class="form-control input-sm" id="alamat" maxlength="200"><?php echo $data['alamat']; ?></textarea>
				</div>
			  </div>
			  <div class="form-group">
				<label class="col-lg-3 control-label small">Provinsi</label>
				<div class="col-lg-7">
				  <select class="form-control input-sm" name="provinsi" id="provinsi">
					<option value=""> - - Pilih Provinsi - - </option>
					<?php
						$provinsi = $koneksi->query("SELECT * from provinsi");
						while ($p = $provinsi->fetch(PDO::FETCH_ASSOC)){
							if($p['id_provinsi'] == $data['id_provinsi']){
								$sp = "selected=selected";
							}else{
								$sp = "";
							}
							echo "<option value=$p[id_provinsi] $sp>$p[provinsi]</option>";
						}
					?>
				  </select>
				</div>
			  </div>
			  <div class="form-group">
				<label class="col-lg-3 control-label small">Kota/Kabupaten</label>
				<div class="col-lg-7">
				  <select class="form-control input-sm" name="kota" id="kabupaten">
					<option value=""> - - Pilih Kota/Kabupaten - - </option>
					<?php
						if($data['id_provinsi'] != ''){
							$kota = $koneksi->query("SELECT * from kabupaten where id_provinsi = $data[id_provinsi]");
							while ($k = $kota->fetch(PDO::FETCH_ASSOC)){
								if($k['id_kabupaten'] == $data['id_kabupaten']){
									$sk = "selected=selected";
								}else{
									$sk = "";
								}
								echo "<option value=$k[id_kabupaten] $sk>$k[kabupaten]</option>";
							}
						}
					?>
				  </select>
				</div>
			  </div>
			  <div class="form-group">
				<label class="col-lg-3 control-label small">Kode Pos</label>
				<div class="col-lg-7">
				  <input type="text" class="form-control input-sm" name="pos" value="<?php echo $data['kd_pos']; ?>" placeholder="Kode Pos..." id="kd_pos" maxlength="10">
				</div>
			  </div>
			  <div class="form-group">
				<label class="col-lg-3 control-label small">Keterangan</label>
				<div class="col-lg-7">
				  <textarea name="keterangan" class="form-control input-sm" maxlength="200"></textarea>
				</div>
			  </div>
			  <div class="form-group">
				<div class="col-lg-offset-3 col-lg-7">
					<input type="reset" class="btn btn-danger btn-sm" name="reset" value="Reset">
				  <input type="submit" class="btn btn-success btn-sm" name="submit" value="Selesai Berbelanja">
				</div>
			  </div>
			</form>
		</div>

	<div class="clearfix"></div>
	</div>
  <div class="clearfix"></div>
  </div>
  <!-- end random product -->

</div>